﻿using FileStorageCenter.Services.Models;
using FileInfo = FileStorageCenter.Services.Models.FileInfo;

namespace FileStorageCenter.EFCore.Data;

public class DataContext : DbContext
{
    public DataContext(DbContextOptions<DataContext> options)
        : base(options)
    {
    }

    public DbSet<FileInfo> FileInfo { get; set; } = default!;
    public DbSet<User> User { get; set; } = default!;

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        _ = modelBuilder.Entity<FileInfo>()
            .HasOne(p => p.AddedBy)
            .WithMany()
            .OnDelete(DeleteBehavior.NoAction);

        base.OnModelCreating(modelBuilder);
    }
}
